package com.imagecollector.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.imagecollector.common.R;
import com.imagecollector.domain.dto.TaskAuditFailDTO;
import com.imagecollector.domain.dto.TaskAuditPassDTO;
import com.imagecollector.domain.dto.TaskAuditSearchDTO;
import com.imagecollector.domain.vo.AuditInfoVO;
import com.imagecollector.service.ITaskAuditRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * <p>
 * 任务审核记录表 前端控制器
 * </p>
 *
 * @author wrf
 * @since 2024-07-31
 */
@Api(tags = "任务审核相关功能接口")
@RestController
@RequestMapping("admin/taskAuditRecord")
public class TaskAuditRecordController {

    @Autowired
    private ITaskAuditRecordService taskAuditRecordService;

    @PostMapping("auditPass")
    @ApiOperation("审核通过")
    public R auditPass(@RequestBody @Valid TaskAuditPassDTO taskAuditPassDTO) {
        taskAuditRecordService.auditPass(taskAuditPassDTO);
        return R.success().msg("操作成功");
    }

    @PostMapping("auditFail")
    @ApiOperation("审核不通过")
    public R auditFail(@RequestBody @Valid TaskAuditFailDTO taskAuditFailDTO) {
        taskAuditRecordService.auditFail(taskAuditFailDTO);
        return R.success().msg("操作成功");
    }

    @PostMapping("auditList")
    @ApiOperation("审核记录列表查询")
    public R auditList(@RequestBody TaskAuditSearchDTO taskAuditSearchDTO){
        Page<AuditInfoVO> res = taskAuditRecordService.auditList(taskAuditSearchDTO);
        return R.success().data("data", res);
    }

    @GetMapping("getAuditRecord")
    @ApiOperation("获取审核记录详细信息")
    public R getAuditRecord(@RequestParam("auditRecordId") @NotNull(message = "审核记录id不能为空") @ApiParam(value = "审核记录id", required = true) Integer auditRecordId){
        AuditInfoVO auditInfoVO = taskAuditRecordService.getAuditRecordById(auditRecordId);
        return R.success().data("data", auditInfoVO);
    }

}
